home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10777 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  43 lines

  1. Path: andrew.cmu.edu!mp52+
  2. From: Matthew Edward Patton <mp52+@andrew.cmu.edu>
  3. Newsgroups: comp.lang.c++
  4. Subject: help: templates + destructors
  5. Date: Sun, 10 Mar 1996 03:28:46 -0500
  6. Organization: Civil and Environmental Engineering, Carnegie Mellon, Pittsburgh, PA
  7. Message-ID: <klEd_y200iWTM=AEsS@andrew.cmu.edu>
  8. NNTP-Posting-Host: po2.andrew.cmu.edu
  9.  
  10. I thought I was getting the hang of c++ but I'm stumped at the following
  11. error.  If anyone could shed some light on this I'd appreciate it
  12. greatly.
  13.  
  14. compiler: g++ v2.5.4 (netbsd)
  15.  
  16. template<class T>
  17. class field {
  18. T value;
  19. public:
  20.   field(void) { value = (T) 0; };
  21.   field(byte) { value = (T) 0; };
  22.   ~field(void) { return; };
  23. }
  24.  
  25. field<char*>::field(void) {
  26. // override class default;
  27. }
  28. field<char*>::field(byte length) {
  29. //override class default;
  30. value = new char[length];
  31. }
  32.  
  33. field<char *>::~field(void) {
  34. delete[] value;
  35. }
  36.  
  37. The error:
  38. no 'field' member function declared in class 'field<char*>'
  39.  
  40. I took that to mean the compiler can't define a custom destructor if a
  41. custom constructor doesn't already exist.  Thing is, I've got two
  42. constructors defined.  I appreciate your help.
  43.